<!DOCTYPE html>
<html lang="zh-CN" style="overflow: hidden;" xmlns:th="http://www.thymeleaf.org"
      xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" layout:decorate="~{shared/layout.html}">

<head>
    <!--styles 样式-->
    <style type="text/css">

    </style>
</head>

<body>
<!--body-->
<th:block layout:fragment="body">
    <div class="m-20" id="app" v-cloak>
        <div class="container-fluid">

            <div class="col-sm-4 offset-sm-4">
                <el-card>
                    <div class="col-sm-12">
                        <h4 class="example-title">旧密码</h4>
                        <input type="text" class="form-control" placeholder="请输入 旧密码" v-model="oldPwd"
                               autocomplete="off"/>
                    </div>
                    <div class="col-sm-12">
                        <h4 class="example-title">新密码</h4>
                        <input type="text" class="form-control" placeholder="请输入 新密码" v-model="newPwd"
                               autocomplete="off"/>
                    </div>
                    <div class="col-sm-12">
                        <h4 class="example-title">确认密码</h4>
                        <input type="text" class="form-control" placeholder="请输入 确认密码" v-model="qrPwd"
                               autocomplete="off"/>
                    </div>

                    <div class="col-sm-12 mt-20 text-center">
                        <button class="btn btn-primary" @click="save">保存</button>
                    </div>
                </el-card>
            </div>

        </div>
    </div>
    <input type="hidden" th:value="${power}" id="power">
    <!--js 脚本-->
    <script type="text/javascript">
        let power = JSON.parse(document.getElementById("power").value);
        let isFindback = 0;
        let app = new Vue({
            el: "#app",
            data: function () {
                return {
                    prefix: '/admin/change/password',
                    grid: 24,
                    oldPwd: null,
                    newPwd: null,
                    qrPwd: null
                }
            },
            created: function () {

            },
            mounted: function () {

            },
            methods: {
                save: function () {
                    let _this = this;
                    let path = _this.prefix + "/save";

                    hzyAdmin.post(path, {
                        oldPwd: this.oldPwd,
                        newPwd: this.newPwd,
                        qrPwd: this.qrPwd
                    }, function (r) {
                        if (r.code != 1) return;
                        hzyAdmin.alert('变更成功!即将退出重新登录', '成功');
                        setTimeout(function () {
                            top.window.location = '/logOut';
                        }, 500);
                    });
                }
            }
        });
    </script>
</th:block>
</body>

</html>